package com.itheima.Demo01.demo01;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;

public class JDK8Date {
    public static void main(String[] args) throws ParseException {
        method();
        LocalDateTime of = LocalDateTime.of(2020, 11, 12, 9, 9, 9);
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd  HH:mm:ss");
        String format = dateTimeFormatter.format(of);
        System.out.println(format);
    }

    private static void method() {
        String s = "2020-11-12  09:09:09";
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd  HH:mm:ss");
        LocalDateTime parse = LocalDateTime.parse(s,dateTimeFormatter);
        System.out.println(parse);
    }
}
